import java.util.Stack;

public class Test {
    //栈的压入、弹出序列
    public class Solution {
        public boolean IsPopOrder (int[] pushV, int[] popV) {
            // write code here
            Stack<Integer> stack=new Stack<>();
            int j=0;
            for (int i = 0; i < pushV.length; i++) {
                stack.push(pushV[i]);
                while(j< popV.length||!stack.empty()||stack.peek()==popV[j]){
                        stack.pop();
                        j++;
                    }
                }
                return stack.empty();
            }
        }


    //有效的括号
    class Solution1 {
        public boolean isValid(String s) {
            Stack<Character> stackl=new Stack<>();
            for (int i = 0; i < s.length(); i++) {
                char ch=s.charAt(i);
                if (ch=='('||ch=='['||ch=='{'){
                    stackl.push(ch);
                }else{
                    if (stackl.empty()){
                        return false;
                    }else{
                        char chl=stackl.peek();
                        if (ch==')'&&chl=='('||ch==']'&&chl=='['
                                ||ch=='}'&&chl=='{'){
                            stackl.pop();
                        }
                    }
                }
            }
            if (stackl.empty()){
                return true;
            }
            return false;
        }
    }
    //MinStack
    public static void main(String[] args) {
        MinStack demo=new MinStack();
        demo.push(1);
        demo.push(-2);
        demo.push(3);
        demo.push(-3);
        demo.pop();
        demo.getMin();
    }

}
